package String;

import java.util.Scanner;

public class test5 {
    public static void main(String[] args) {
        //1.键盘录入一个金额
        Scanner sc = new Scanner(System.in);
        int money;
        while (true) {
            System.out.println("请输入一个金额");
            money = sc.nextInt();
            if (money >= 0 && money <= 9999999) {
                break;
            } else {
                System.out.println("金额无效");
            }
        }
//        System.out.println(money);

        String moneyStr = "";
        //2.得到money中的每一位
        while (true) {
            int ge = money % 10;

            String capitalNum = getCapitalNumber(ge);

            moneyStr = capitalNum + moneyStr;

            money = money / 10;

            if (money == 0) {
                break;
            }
        }
//        System.out.println(moneyStr);

        //3.在前面补零，补齐7位
        int count = 7 - moneyStr.length();
        for (int i = 0; i < count; i++) {
            moneyStr = "零" + moneyStr;
        }
        System.out.println(moneyStr);

        //4.插入单位
        String[] arr = {"佰", "拾", "万", "仟", "佰", "拾", "元"};
        String res = "";
        for (int i = 0; i < moneyStr.length(); i++) {
            char c = moneyStr.charAt(i);
            res = res + c + arr[i];
        }
        System.out.println(res);
    }

    public static String getCapitalNumber(int number) {
        String[] arr = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        return arr[number];
    }
}
